<?php

namespace App\Jobs\User;

use App\Models\User\Repositories\Interfaces\UserRepositoryInterface;
use App\Models\User\User;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessUserAvatar implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private User $user;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Execute the job.
     *
     * @return void
     * @throws GuzzleException
     * @throws Exception
     */
    public function handle()
    {

        $userRepo = app(UserRepositoryInterface::class);
        $userRepo->updateUserAvatar($this->user);


    }

    public function uniqueId(): string
    {
        return $this->user->getUnionId();
    }
}
